package top.wshape1.shiziapi.project.controller;

import jakarta.annotation.Resource;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import top.wshape1.shiziapi.common.constant.AuthConstant;
import top.wshape1.shiziapi.common.domain.CommonUser;
import top.wshape1.shiziapi.common.utils.Base64Util;
import top.wshape1.shiziapi.common.utils.R;
import top.wshape1.shiziapi.project.service.ReadService;

import java.util.List;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-01-22
 */

@RestController
@RequestMapping("/read")
public class ReadController {

    @Resource
    private ReadService readService;

    /**
     * 浏览量+1
     * @param projectId
     * @return
     */
    @PostMapping("/read/{projectId}")
    public R<Void> read(@PathVariable Long projectId) {

        readService.read(projectId);

        return R.ok();
    }

    /**
     * 获取单个的浏览量
     * @param projectId
     * @return
     */
    @GetMapping("/count/{projectId}")
    public R<Long> count(@PathVariable Long projectId) {

        long count = readService.countRead(projectId);

        return R.ok(count);
    }

}
